package com.ruoyi.yx.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.*;
import com.ruoyi.framework.web.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api("管控api")
@RequestMapping("/api/control")
public class ControlController extends BaseController {

    @Autowired
    private WeChatService weChatService;

    @Autowired
    private AppInfoService appInfoService;

    @Autowired
    private ControlService controlService;

    @Autowired
    private LocationService locationService;

    @Autowired
    private DeviceService deviceService;

    @Autowired
    private DeviceNoticeMessageService deviceNoticeMessageService;

    @Autowired
    private FeedBackService feedBackService;

    /**
     * 一键锁屏
     * @return
     * @throws Exception
     */
    @PostMapping("/lockScreen")
    @ApiOperation("一键锁屏")
    public R<String> lockScreen(@RequestBody String taskId)throws Exception{
        return controlService.lockScreen(taskId);
    }

    /**
     * 一键解锁
     * @return
     * @throws Exception
     */
    @PostMapping("/unLockScreen")
    @ApiOperation("一键解锁")
    public R<String> unLockScreen(@RequestBody String taskId)throws Exception{
        return controlService.unLockScreen(taskId);
    }

    /**
     * 获取远程 桌面截图
     * @return
     * @throws Exception
     */
    @PostMapping("/captureDesktop")
    @ApiOperation("获取远程 桌面截图")
    public R<String> captureDesktop(@RequestBody String taskId)throws Exception{
        return controlService.captureDesktop(taskId);
    }

    /**
     * 开始同屏监管
     * @return
     * @throws Exception
     */
    @PostMapping("/live/captureDesktop/start")
    @ApiOperation("开始同屏监管")
    public R<String> captureDesktopLiveStart(@RequestBody String taskId)throws Exception{
        return controlService.captureDesktopLiveStart(taskId);
    }

    /**
     * 查询任务数据
     * @return
     * @throws Exception
     */
    @PostMapping("/task/query")
    @ApiOperation("查询任务数据")
    public R<String> queryTaskData(@RequestBody String taskId)throws Exception{
        return controlService.queryTaskData(taskId);
    }

    /**
     * 结束同屏监管
     * @return
     * @throws Exception
     */
    @PostMapping("/live/captureDesktop/stop")
    @ApiOperation("结束同屏监管")
    public R<String> captureDesktopLiveStop(@RequestBody String taskId)throws Exception{
        return controlService.captureDesktopLiveStop(taskId);
    }

    /**
     * 上传设备管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/deviceUseTime/update")
    @ApiOperation("上传设备管控时间")
    public R<String> updateDeviceUseTime(@RequestBody YxDeviceUseTimeVo deviceUseTimeVo)throws Exception{
        return controlService.updateDeviceUseTime(deviceUseTimeVo);
    }

    /**
     * 一键清理设备管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/deviceUseTime/clearAll")
    @ApiOperation("一键清理设备管控时间")
    public R<String> clearAllDeviceUseTime(@RequestBody YxDeviceUseTimeVo deviceUseTimeVo)throws Exception{
        return controlService.clearAllDeviceUseTime();
    }

    /**
     * 获取设备应用使用时间列表
     * @return
     * @throws Exception
     */
    @PostMapping("/wx/deviceAppAndUseTimeList")
    @ApiOperation("获取设备应用使用时间列表")
    public R<List<YxDeviceAppUseTimeAndWeekVo>> appDeviceAppAndUseTimeList()throws Exception{
        return controlService.wxGetAppUseTimeList();
    }

    /**
     * 获取设备应用使用时间列表
     * @return
     * @throws Exception
     */
    @PostMapping("/device/appAndUseTimeList")
    @ApiOperation("获取设备应用使用时间列表")
    public R<List<YxDeviceAppUseTimeAndWeekVo>> deviceAppUseTimeList()throws Exception{
        return controlService.deviceAppUseTimeList();
    }

    /**
     * 获取设备管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/device/useTime")
    @ApiOperation("获取设备管控时间")
    public R<YxDeviceUseTimeVo> getDeviceAppUseTime()throws Exception{
        return controlService.getUseTimeByDevice();
    }

    /**
     * 通知设备开始立即上传通知信息
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadDeviceNoticeMessgaeImmediately")
    @ApiOperation("通知设备开始立即上传通知信息")
    public R<String> uploadDeviceNoticeMessgaeImmediately()throws Exception{
        return controlService.uploadDeviceNoticeMessgaeImmediately();
    }

    /**
     * 上传设备应用管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/deviceAppUseTime/update")
    @ApiOperation("上传设备应用管控时间")
    public R<String> updateDeviceAppUseTime(@RequestBody YxDeviceUseTimeVo deviceUseTimeVo)throws Exception{
        return controlService.updateDeviceAppUseTime(deviceUseTimeVo);
    }

    /**
     * 一键清理设备应用管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/deviceAppUseTime/clearAll")
    @ApiOperation("一键清理设备应用管控时间")
    public R<String> clearAllDeviceAppUseTime(@RequestBody YxDeviceUseTimeVo deviceUseTimeVo)throws Exception{
        return controlService.clearAllDeviceAppUseTime(deviceUseTimeVo);
    }


    /**
     * 获取设备应用 管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/deviceAppUseTime/get")
    @ApiOperation("获取设备应用 管控时间")
    public R<YxDeviceUseTimeVo> getDeviceAppUseTime(@RequestBody Long daId)throws Exception{
        return controlService.getDeviceAppUseTime(daId);
    }


    /**
     * 获取授权应用列表
     * @return
     * @throws Exception
     */
    @PostMapping("/app/authorized/list")
    @ApiOperation("获取授权应用列表")
    public R<List<YxAndroidApplicationVo>> appAuthorizeList()throws Exception{
        return appInfoService.appAuthorizeList();
    }





    /**
     * 获取设备管控时间
     * @return
     * @throws Exception
     */
    @PostMapping("/wx/deviceUseTime/get")
    @ApiOperation("获取设备管控时间")
    public R<YxDeviceUseTimeVo> getDeviceUseTime()throws Exception{
        return controlService.getDeviceUseTime();
    }




}
